package localhost.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;

import localhost.ejb.Somavel;

@Entity
@Table(name = "parcelado")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Parcelado.findAll", query = "SELECT p FROM Parcelado p"),
    @NamedQuery(name = "Parcelado.findByIdparcelado", query = "SELECT p FROM Parcelado p WHERE p.id = :idparcelado"),
    @NamedQuery(name = "Parcelado.findByDia", query = "SELECT p FROM Parcelado p WHERE p.dia = :dia"),
    @NamedQuery(name = "Parcelado.findByTipo", query = "SELECT p FROM Parcelado p WHERE p.tipo = :tipo"),
    @NamedQuery(name = "Parcelado.findByValor", query = "SELECT p FROM Parcelado p WHERE p.valor = :valor"),
    @NamedQuery(name = "Parcelado.findByDescricao", query = "SELECT p FROM Parcelado p WHERE p.descricao = :descricao")})

public class Parcelado implements Serializable, Somavel {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "dia")
    private int dia;// o dia do vencto
    @Basic(optional = false)
    @Column(name = "qtd")
    private int qtd;// quantidade de parcelas
    @Basic(optional = false)
    @Column(name = "tipo")
    private String tipo;// entrada , saída
    @Basic(optional = false)
    @ManyToOne
    private Conta conta;
    @Basic(optional = false)
    @Column(name = "valor")
    private Double valor;
    @Basic(optional = false)
    @Column(name = "descricao")
    private String descricao;
    @Basic(optional = false)
    @Column(name = "dtaini")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtaini;
    @Transient
    @Temporal(TemporalType.TIMESTAMP)
    private Date dtafim;

    public Parcelado() {
    	
    }

    public Parcelado(Integer idparcelado) {
        this.id = idparcelado;
    }

    public Parcelado(Integer idparcelado, int regra, int dia, int repetir, String tipo, Double valor, String descricao) {
        this.id = idparcelado;
        this.dia = dia;
        this.qtd = repetir;
        this.tipo = tipo;
        this.valor = valor;
        this.descricao = descricao;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer idparcelado) {
        this.id = idparcelado;
    }

    public int getDia() {
        return dia;
    }

    public void setDia(int dia) {
        this.dia = dia;
    }

    public int getQtd() {
        return qtd;
    }

    public void setQtd(int repetir) {
        this.qtd = repetir;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public Double getValor() {
        return valor;
    }

    public void setValor(Double valor) {
        this.valor = valor;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    public Date getDtaini() {
		return dtaini;
	}

	public void setDtaini(Date dtaini) {
		this.dtaini = dtaini;
	}

	public Conta getConta() {
		return conta;
	}

	public void setConta(Conta conta) {
		this.conta = conta;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Parcelado)) {
            return false;
        }
        Parcelado other = (Parcelado) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    public Date getDtafim() {
		return dtafim;
	}

	public void setDtafim(Date dtafim) {
		this.dtafim = dtafim;
	}

	@Override
	public String toString() {
		return "Parcelado [id=" + id + ", dia=" + dia + ", qtd=" + qtd
				+ ", tipo=" + tipo + ", conta=" + conta + ", valor=" + valor
				+ ", descricao=" + descricao + ", dtaini=" + dtaini
				+ ", dtafim=" + dtafim + "]";
	}


    
}